<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
export default {
  data () {
    return {
      cdata: {
        category: [
          "09-30",
          "10-01",
          "10-02",
          "10-03",
          "10-04",
          "10-05",
          "10-06",
          "10-07",
          "10-08",
          "10-09",
          "10-10",
          "10-11",
          "10-12",
          "10-13",
          "10-14",
          "10-15",
          "10-16",
          "10-17",
          "10-18",
          "10-19",
          "10-20",
          "10-21",
          "10-22",
          "10-23",
          "10-24",
          "10-25",
          "10-26",
          "10-27",
          "10-28",
          "10-29",
          "10-30",
          "10-31",
          "11-01"
        ],
        lineData: [
          180,
          207,
          240,
          283,
          328,
          360,
          396,
          441,
          484,
          545,
          561,
          627,
          591,
          670,
          182,
          208,
          245,
          288,
          328,
          367,
          397,
          445,
          484,
          505,
          397,
          387,
          445,
          484,
          505,
          501,
          367,
          491,
          328
        ],
        barData: [
          46,
          50,
          55,
          60,
          70,
          80,
          90,
          150,
          140,
          215,
          230,
          244,
          252,
          330,
          46,
          50,
          55,
          65,
          75,
          85,
          99,
          225,
          140,
          210,
          85,
          99,
          120,
          140,
          210,
          200,
          240,
          250,
          70
        ],
        rateData: []
      }
    };
  },
  components: {
    Chart,
  },
  mounted () {
    this.setData();
  },
  methods: {
    // 根据自己的业务情况修改
    setData () {
      for (let i = 0; i < this.cdata.barData.length -1; i++) {
        // let rate = this.cdata.barData[i] / this.cdata.lineData[i];
        // this.cdata.rateData.push(rate.toFixed(2));
        let rate = this.cdata.lineData[i] -this.cdata.barData[i];
        this.cdata.rateData.push(rate);
      }
    },
  }
};
</script>

<style lang="scss" scoped>
</style>
